package io.zhoujie.modules.app.utils;

import java.util.HashSet;
import java.util.Set;

public class SensitiveWordChecker {

    // 敏感词集合  
    private static Set<String> sensitiveWords = new HashSet<>();

    static {
        sensitiveWords.add("政治");
        sensitiveWords.add("色情");
        sensitiveWords.add("暴力");
        sensitiveWords.add("股市");
        sensitiveWords.add("上帝");
    }

    public SensitiveWordChecker(Set<String> sensitiveWords) {
        this.sensitiveWords = sensitiveWords;
    }

    /**
     * 检查文本是否包含敏感词
     *
     * @param content 要检查的文本
     * @return 如果包含敏感词则返回true，否则返回false
     */
    public static boolean containsSensitiveWord(String content) {
        /**
         * 添加敏感词汇
         */
        if (content == null || content.isEmpty()) {
            return false;
        }
        for (String word : sensitiveWords) {
            if (content.contains(word)) {
                return true;
            }
        }
        return false;
    }
}